<?php
require_once 'common.php';

if ($_SERVER['REQUEST_METHOD']!='POST') {
    echo json_encode(['status' => 'fail']);
    exit;
}

$params = file_get_contents('php://input');
try {
    $params = json_decode($params, true);
    $res = SQLiteDB::addRow($params);

    if ($res) {
        echo json_encode(['status' => 'success']);
    } else {
        echo json_encode(['status' => 'fail']);
    }
} catch (Exception $e) {
    echo json_encode(['status' => 'fail', 'message' => $e->getMessage()]);
}